/*
 * soundManagerInit
 * this class intializes soundManager, object created in scriptfile soundmanager2.js
 * if you want to use some sound, you must put soundfile in folder document_root/js/libs/soundmanager/sounds
 * after that, you must define this sound
 * this definition must be done in this file, ecpecially in object soundManagement, function initialize, function onready
 * you will assing call of function soundManager.createSound({...}) with all needed properties(id and url of sound) to 
 * new variable in soundManagement.sounds
 * if you want to use sounds on some page, you will include this:
 * 
 * <script type="text/javascript" src="{$basePath}/js/libs/soundmanager/soundManagerInit.js"></script>
 * <script type="text/javascript" src="{$basePath}/js/libs/soundmanager/script/soundmanager2.js"></script>
 * 
 * this will write much information to the console, if you dont want to be anything written into the console, use this:
 * 
 * <script type="text/javascript" src="{$basePath}/js/libs/soundmanager/soundManagerInit.js"></script>
 * <script type="text/javascript" src="{$basePath}/js/libs/soundmanager/script/soundmanager2-nodebug.js"></script>
 * 
 * then, if you want to play sound, just call soundManagement.play("soundname");
 * soundname must correspond to variable name where you stored the object with sound
 */

var soundManagement = {
    sounds:{},
    isInitialized:"undefined",
    initialize : function(){
        isInitialized=true;
        soundManager.setup({
            url: 'http://localhost/celebrio/document_root/js/libs/soundmanager/swf/',
            onready:function(){
                console.log("hello world from initialization");
                
                soundManagement.sounds.defaultSound = soundManager.createSound({
                    'id':'defaultSound',
                    'url':'http://localhost/celebrio/document_root/sounds/button-12.mp3'
                });
                
                soundManagement.sounds.message = soundManager.createSound({
                    'id':'message',
                    'url':'http://localhost/celebrio/document_root/sounds/button-1.mp3'
                });
            }
        });
       
    },
    play : function(soundName){
        if(typeof soundManagement.sounds[soundName]==="undefined"){
            soundManagement.sounds["defaultSound"].play();
            console.log("sound name not recognized");
        }
        else soundManagement.sounds[soundName].play();
            
        
    }
}

soundManagement.initialize();